package com.neusoft.bizcore.auth.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.auth.enums.AuthPermissionType;
import com.neusoft.bizcore.web.jpa.model.AbstractModel;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AuthPermission extends AbstractModel {

    private static final long serialVersionUID = 1L;

    /** 权限名 */
    @NotBlank(message = "权限名不能为空")
    @Length(max = 255, message = "权限名不能超过{max}位")
    @Column(length = 255, nullable = false)
    private String name;

    /** 权限标识 */
    @NotBlank(message = "权限标识不能为空")
    @Length(max = 255, message = "权限标识不能超过{max}位")
    @Column(length = 255, nullable = false, unique = true)
    private String code;

    /** 权限类型 */
    @Enumerated(EnumType.STRING)
    @NotNull(message = " 权限类型不能为空")
    @Column(nullable = false)
    private AuthPermissionType type;

    /** 所属应用 */
    @ManyToOne
    private AuthContentType contentType;

}
